home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94b.txt / 000063_icon-group-sender _Wed Sep 21 09:12:45 1994.msg < prev    next >
Internet Message Format  |  1995-02-09  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Wed, 21 Sep 1994 04:36:08 MST
  2. Message-Id: <9409210805.AA06761@eithne.aldiscon.ie>
  3. From: Simon Chapman <simonc@aldiscon.ie>
  4. Subject: Re: Question: conjunction in Icon and C
  5. To: Art Eschenlauer <eschen@molbio.cbs.umn.edu>
  6. Date: Wed, 21 Sep 1994 09:12:45 +0100 (BST)
  7. Cc: icon-group@cs.arizona.edu
  8. In-Reply-To: <9409202041.AA18914@molbio.cbs.umn.edu> from "Art Eschenlauer" at Sep 20, 94 03:41:27 pm
  9. X-Mailer: ELM [version 2.4 PL23]
  10. Content-Type: text
  11. Content-Length: 1212      
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13.  
  14. Art Eschenlauer scribbles:
  15. > I have a C question that Icon'ers are more likely to understand than the
  16. > average run-of-the-mill C programmer, so here goes.
  17.  
  18.     I'm sure that C programmers would actually be better, but anyhow ....
  19. > In Icon, if I say:
  20. > if <expr1> & <expr2> then <expr3> else <expr4>
  21. > and <expr1> fails, <expr2> will not be evaluated.
  22. > In C, if I say:
  23. > if ( <expr1> && <expr2> ) <expr3>; else <expr4>;
  24. > and <expr1> has a value of zero (NULL, etc.), is it defined (in the ANSI 
  25. > standard, I guess) whether <expr2> will be evaluated or is this compiler 
  26. > specific?
  27.  
  28.     Looking at my Que C Quick Reference and ANSI K & R, the two logical
  29.     operators && and || are subject to what the former calls
  30.     "Short Circuit Evaluation" which does as you say, namely if
  31.     <expr1> evaluates to 0, <expr2> will NOT be evaluated. Both operators
  32.     guaranteed left to right evaluation.
  33.  
  34.  
  35. -- 
  36.  
  37. +-------------------------------------------------+
  38. | Aldiscon Ltd.,     | simon chapman              |
  39. | Hambleden House,   | simonc@aldiscon.ie         |
  40. | Lwr. Pembroke St., | Ph.: +353.1.6053183 direct |
  41. | Dublin 2, Ireland. | (incl. Voice mail )        |
  42. +-------------------------------------------------+
  43.